package com.ydgg.ltar.api;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ydgg.ltar.model.Version;
import com.ydgg.ltar.service.VersionService;


@Controller
@RequestMapping(value = "api/version", produces = "application/json;charset=UTF-8")
public class VersionApi {
	
	@Autowired
	private VersionService versionService;

	
	@ResponseBody
	@RequestMapping("/judge")
	public String judge(){
		return "1";
	}
	
	@ResponseBody
	@RequestMapping("/version")
	public ApiResult version(){
        ApiResult result = new ApiResult();
    	String where = " order by id desc limit 0,1";
    	List<Version> list = versionService.selectByWhere(where);
    	if(list.size() > 0){
    		result.msg.desc = "获取成功";
    		result.msg.status = 0;
    		result.data.put("appsize", list.get(0).getAppsize());
    		result.data.put("description", list.get(0).getDescription());
    		result.data.put("id", list.get(0).getId());
    		result.data.put("remark", list.get(0).getRemark());
    		result.data.put("updatetime", list.get(0).getUpdatetime());
    		result.data.put("updateurl", list.get(0).getUpdateurl());
    		result.data.put("versioncode", list.get(0).getVersioncode());
    		result.data.put("versionname", list.get(0).getVersionname());
    	}else{
    		result.msg.status = 1;
			result.msg.desc = "暂无最新版本";
		}
    return result;
	}
}
